import java.util.*;
public class NoOfTriangles{
	static int findNoOfTriangles(int input[], int n){
		int triangleCount = 0;
		int iPointer, jPointer, kPointer;
		if(n < 3) return 0;
		iPointer = 0;
		
	while(iPointer < n)
	{
		jPointer = iPointer + 1;
		kPointer = iPointer + 2;
		while(jPointer < n)
		{
			while(kPointer<n && (input[iPointer]+input[jPointer] > input[kPointer]))
			{
				kPointer+=1;
			}
			kPointer-=1;
			triangleCount+=kPointer-jPointer;
			jPointer+=1;
		}
		iPointer+=1;
	}
	return triangleCount;
	}

	public static void main(String[] args) {
		int[] input ={10, 21, 22, 100, 101, 200, 300};
		Arrays.sort(input);
		System.out.println(findNoOfTriangles(input, input.length));
	}
}